﻿'This file is part of Alpha.
'
'   Alpha is free software: you can redistribute it and/or modify
'   it under the terms of the GNU Lesser General Public License as published by
'   the Free Software Foundation, either version 3 of the License, or
'   (at your option) any later version.
'
'   Alpha is distributed in the hope that it will be useful,
'   but WITHOUT ANY WARRANTY; without even the implied warranty of
'   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'   GNU Lesser General Public License for more details.
'
'   You should have received a copy of the GNU Lesser General Public License
'   along with Alpha.  If not, see <http://www.gnu.org/licenses/>.

Public MustInherit Class Controller
    Implements IDisposable

    Protected Sub New()
    End Sub

    'Return version information, eg. Blah Media Controller v3.54.6
    Public MustOverride ReadOnly Property Version() As String

    'Return copyright information, eg. Copyright Joe Bloggs 1874.
    Public Overridable ReadOnly Property Copyright() As String
        Get
            Return "Copyright Matthew Wilkinson 2008-2009."
        End Get
    End Property

    'Return an Array of supported actions
    Public MustOverride ReadOnly Property SupportedActions() As Collections.ObjectModel.ReadOnlyCollection(Of Action)

    'All of the following will just throw an NotSupportedException if they are not explicity overridden in the child class

#Region " Playback "

    Public Overridable Sub Play()
        Throw New NotSupportedException
    End Sub

    Public Overridable Sub PlayPause()
        Throw New NotSupportedException
    End Sub

    Public Overridable Sub Pause()
        Throw New NotSupportedException
    End Sub

    Public Overridable Sub StopPlayback()
        Throw New NotSupportedException
    End Sub

    Public Overridable Sub NextTrack()
        Throw New NotSupportedException
    End Sub


    Public Overridable Sub PreviousTrack()
        Throw New NotSupportedException
    End Sub

    'There is a subtle difference between PrevTrack and BackTrack.
    'Some players go to the start of the current song with PrevTrack if it has played a bit, or go to the previous track if it's only about 3 or so seconds in.
    'BackTrack ALWAYS goes to the previous track, no matter the time elapsed
    'Therefore be careful when defining either of these subs to be sure it is implementing the correct behaviour on the player
    Public Overridable Sub BackTrack()
        Throw New NotSupportedException
    End Sub

    Public Overridable Sub Seek()
        Throw New NotSupportedException
    End Sub

    Public Overridable Property Repeat() As Boolean
        Get
            Throw New NotSupportedException
        End Get
        Set(ByVal repeat As Boolean)
            Throw New NotSupportedException
        End Set
    End Property

    Public Overridable Sub ToggleRepeat()
        Throw New NotSupportedException
    End Sub

    Public Overridable Property Shuffle() As Boolean
        Get
            Throw New NotSupportedException
        End Get
        Set(ByVal shuffle As Boolean)
            Throw New NotSupportedException
        End Set
    End Property

    Public Overridable Sub ToggleShuffle()
        Throw New NotSupportedException
    End Sub

    Public Overridable Property Random() As Boolean
        Get
            Throw New NotSupportedException
        End Get
        Set(ByVal random As Boolean)
            Throw New NotSupportedException
        End Set
    End Property

    Public Overridable Sub ToggleRandom()
        Throw New NotSupportedException
    End Sub

#End Region

#Region " Volume "

    'Should return/accept an integer from 1 to 100 (as in percent)
    Public Overridable Property Volume() As Integer
        Get
            Throw New NotSupportedException
        End Get
        Set(ByVal volume As Integer)
            Throw New NotSupportedException
        End Set
    End Property

    'Should increase volume by 10% if possible, if not then it should be the media player's built in function
    Public Overridable Sub VolumeUp()
        Volume = Volume + 10
    End Sub

    'As above, but decrease
    Public Overridable Sub VolumeDown()
        Volume = Volume - 10
    End Sub

    Public Overridable Property Mute() As Boolean
        Get
            Throw New NotSupportedException
        End Get
        Set(ByVal mute As Boolean)
            Throw New NotSupportedException
        End Set
    End Property

    Public Overridable Sub ToggleMute()
        Throw New NotSupportedException
    End Sub

#End Region

#Region " Track"

    Public Overridable ReadOnly Property Track() As Track
        Get
            Throw New NotSupportedException
        End Get
    End Property

    'Return in seconds
    'I realise this can be merged with the Seek Sub, but I decided to leave them as two separate things
    Public Overridable ReadOnly Property TimeElapsed() As Integer
        Get
            Throw New NotSupportedException
        End Get
    End Property

#End Region

    Public Event TrackChanged()

#Region " IDisposable Support "

    Protected Overridable Sub Dispose(ByVal disposing As Boolean)
    End Sub

    Public Sub Dispose() Implements IDisposable.Dispose
        Dispose(True)
        GC.SuppressFinalize(Me)
    End Sub

#End Region

End Class

